package com.zxbit.flash.common;

import com.zxbit.flash.PopApplication;
import com.zxbit.flash.R;
import com.zxbit.flash.bean.IdentityData;

import java.util.Arrays;
import java.util.List;

public class RealNameAuthData {
    private static RealNameAuthData instance = new RealNameAuthData();
    private static IdentityData.IdentityBean identityBean = new IdentityData.IdentityBean();


    private RealNameAuthData() {

    }

    public static RealNameAuthData getInstance() {
        if (instance == null) {
            instance = new RealNameAuthData();
        }
        return instance;
    }

    public void putAllData(IdentityData.IdentityBean bean) {
        identityBean = bean;
    }

    public IdentityData.IdentityBean getAllData() {
        return identityBean;
    }

    public void putData(String key, String value) {
        List<String> arr = Arrays.asList(PopApplication.getContext().getResources().getStringArray(R.array.identity));

        if (key.equals(arr.get(0))) {
            identityBean.setRealName(value);
        } else if (key.equals(arr.get(1))) {
            identityBean.setIdentityCardNum(value);
        } else if (key.equals(arr.get(2))) {
            identityBean.setBloodType(value);
        } else if (key.equals(arr.get(3))) {
            identityBean.setReligion(value);
        } else if (key.equals(arr.get(4))) {
            identityBean.setGender(value);
        } else if (key.equals(arr.get(5))) {
            identityBean.setBirthday(value);
        } else if (key.equals(arr.get(6))) {
            identityBean.setBirthPlace(value);
        } else if (key.equals(arr.get(7))) {
            identityBean.setProvince(value);
        } else if (key.equals(arr.get(8))) {
            identityBean.setCity(value);
        } else if (key.equals(arr.get(9))) {
            identityBean.setDistrict(value);
        } else if (key.equals(arr.get(10))) {
            identityBean.setVillage(value);
        } else if (key.equals(arr.get(11))) {
            identityBean.setAddress(value);
        } else if (key.equals(arr.get(12))) {
            identityBean.setRt(value);
        } else if (key.equals(arr.get(13))) {
            identityBean.setRw(value);
        } else if (key.equals(arr.get(14))) {
            identityBean.setNationality(value);
        } else if (key.equals(arr.get(15))) {
            identityBean.setMaritalStatus(value);
        } else if (key.equals(arr.get(16))) {
            identityBean.setOccupation(value);
        } else if (key.equals(arr.get(17))) {
            identityBean.setExpiryDate(value);
        }
    }

    public String getData(String key) {
        List<String> arr = Arrays.asList(PopApplication.getContext().getResources().getStringArray(R.array.identity));
        String result = "";
        if (key.equals(arr.get(0))) {
            result = identityBean.getRealName();
        } else if (key.equals(arr.get(1))) {
            result = identityBean.getIdentityCardNum();
        } else if (key.equals(arr.get(2))) {
            result = identityBean.getBloodType();
        } else if (key.equals(arr.get(3))) {
            result = identityBean.getReligion();
        } else if (key.equals(arr.get(4))) {
            result = identityBean.getGender();
        } else if (key.equals(arr.get(5))) {
            result = identityBean.getBirthday();
        } else if (key.equals(arr.get(6))) {
            result = identityBean.getBirthPlace();
        } else if (key.equals(arr.get(7))) {
            result = identityBean.getProvince();
        } else if (key.equals(arr.get(8))) {
            result = identityBean.getCity();
        } else if (key.equals(arr.get(9))) {
            result = identityBean.getDistrict();
        } else if (key.equals(arr.get(10))) {
            result = identityBean.getVillage();
        } else if (key.equals(arr.get(11))) {
            result=identityBean.getAddress();
        } else if (key.equals(arr.get(12))) {
            result=identityBean.getRt();
        } else if (key.equals(arr.get(13))) {
            result=identityBean.getRw();
        } else if (key.equals(arr.get(14))) {
            result=identityBean.getNationality();
        } else if (key.equals(arr.get(15))) {
            result=identityBean.getMaritalStatus();
        } else if (key.equals(arr.get(16))) {
            result=identityBean.getOccupation();
        } else if (key.equals(arr.get(17))) {
            result=identityBean.getExpiryDate();
        }
        return result;

    }

}
